﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Repetition.Domain
{
    public class Subject
    {
        public virtual int Id { get; set; }
        public virtual string Name { get; set; }
        public virtual string Details { get; set; }

        public Subject()
        {
            // Name needs to be initialized so that GetHashCode can be called on an empty subject.
            Name = "";
            Details = "";
        }

        public Subject(string name)
            : this(name, "") { }

        public Subject(string name, string details)
        {
            Name = name;
            Details = details;
        }

        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return false;
            }

            var right = (Subject)obj;

            return Name == right.Name && Details == right.Details;
        }

        public override int GetHashCode()
        {
            return Name.GetHashCode();
        }

        public virtual void Copy(Subject subject)
        {
            this.Name = subject.Name;
            this.Details = subject.Details;
        }
    }
}
